<template>
  <div class="content-container-item" :class="{'top-1':idx===1,'top-2':idx===2,'top-3':idx===3}">
    <div class="flex">
      <span class="content-container-item-num" >{{ idx }}</span>
      <span class="text-ellipsis content-container-item-name" :title="item.name" >{{ item.name }} <span >{{ item.card }}</span></span>
    </div>
    <span  class="unit">{{item.caseBehavior}}</span>
  </div>
</template>

<script>
import DproPercentageNumber from "../percentage-number/index.vue";
import { formatBigNum } from './utils/string';

export default {
  name: 'DproContentItem',
  props: {
    item: {
      type: Object,
      default: {}
    },
    idx: {
      type: [String, Number],
      default: '0'
    },
    activeIdx: {
      type: [String, Number],
      default: '0'
    },
  },
  components: { DproPercentageNumber },
  data() {
    return {}
  },
  computed: {
    getNum() {
      return this.idx < 10 ? '0' + (this.idx) : this.idx
    }
  },
  methods: {
    formatBigNum
  }
}
</script>

<style lang="less" scoped>
.flex {
  display: flex;
  align-items: center;
}

.text-ellipsis {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-container-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 10px;
  line-height: 32px;
  font-size: 14px;
  color: var(--primary-text, #fff);
  font-weight: 400;
  // border-radius: 16px;
  cursor: pointer;
  .content-caseBehavior{
    max-width: 16ch;  // 1个汉字≈2ch
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  //鼠标滑过显示全部内容
  .content-caseBehavior-hover{
    position: relative;
    &::after {
      content: attr(title);
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%);
      background: #333;
      color: #fff;
      padding: 4px 8px;
      border-radius: 4px;
      font-size: 12px;
      white-space: nowrap;
      opacity: 0;
      transition: opacity 0.2s;
      pointer-events: none;
    }
    &:hover::after {
      opacity: 1;
    }
  }
}

.content-container-item-num {
  display: inline-block;
  width: 25px;
  height: 25px;
  margin-right: 20px;
  text-align: center;
  opacity: 0.5;
  font-size: 20px;
}

.content-container-item-name {
  font-size: 20px;
  color: var(--primary-text, #fff);
}

.content-container-item-line {
  width: 150px;
  height: 10px;
  background: rgba(255, 255, 255, .2);
  border-radius: 16px;
}

.content-container-item-line div {
  height: 10px;
  background: rgba(255, 255, 255, .5);
  border-radius: 16px;
}

.content-container-item.top-1 {
  line-height: 38px;
  //background-color: rgba(255, 255, 255, .1);
  font-weight: 600;
}

.content-container-item.top-2, .content-container-item.top-3 {
  font-weight: 600;
}

.content-container-item.top-1 .content-container-item-line div {
  background: rgba(255, 255, 255, 1);
}

.top-1 .content-container-item-num, .top-2 .content-container-item-num, .top-3 .content-container-item-num {
  display: inline-block;
  width: 25px;
  height: 25px;
  background: #FB6501;
  border-radius: 50%;
  font-size: 20px;
  line-height: 24px;
  font-weight: 700;
  text-align: center;
  opacity: 1;

}

.top-2 .content-container-item-num {
  background: #FFA40E;
}

.top-3 .content-container-item-num {
  background: #1C69EE;
}

.top-1 .content-container-item-name, .top-2 .content-container-item-name, .top-3 .content-container-item-name {
  font-size: 20px;
  line-height: 24px;
  font-weight: 700;
}

.top-2 .content-container-item-name, .top-3 .content-container-item-name {
  font-size: 20px;
}

.top-1 > span {
  //font-size: 20px;
}

.unit {
  width: 50%;
  margin-left: 4px;
  font-size: 20px;
  //opacity: 0.5;
  text-align: center;
  font-weight: 400;
}

.top-1 .unit, .top-2 .unit, .top-3 .unit {
  opacity: 1;
}
</style>